const RecomWeightAdvanceModel = require('../db/models/recommend_weight_advance');
//修改

class RecomWeightAdvanceServer { //修改
  //修改
  async addRecomWeightAdvance (data) {
    const userId = data.userId;

    if(!userId) {
      return;
    }

    //修改
    const result = await RecomWeightAdvanceModel.findOne({where: { userId }});
    //判断 check
    if (result) { 
      //更新 update  //修改
      return await RecomWeightAdvanceModel.update(data, {where: { userId }})
    }else {
      //创建 create
      return await RecomWeightAdvanceModel.create(data);
    }
  }

  async findRecomWeightAdvanceById (userId) {
    return await RecomWeightAdvanceModel.findOne({where: { userId }});
  }


}
//修改
module.exports = new RecomWeightAdvanceServer();